package nciae.db.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import nciae.db.pojo.entity.HomeworkDetail;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface HomeworkDetailMapper extends BaseMapper<HomeworkDetail> {

    @Select("select avg(score) from homework_detail where student_id=#{userId}")
    Double getAvgerage(Integer userId);

    @Delete("delete from homework_detail where homework_id=#{homeworkId}")
    void deleteHomework(Integer homeworkId);
    /**
     * 根据用户id返回所有HomeworkDetail对象
     * @param userId
     * @return
     */
    @Select("select * from homework_detail where student_id=#{userId}")
    List<HomeworkDetail> getHomeworkDetails(Integer userId);

    @Delete("delete from homework_detail where id=#{id}")
    void delHomeworkDetails(Integer id);

}
